{"ast":null,"code":"import React from'react';import{DialogItem}from\"../index\";import{InputBase}from\"@mui/material\";import\"./Dialogs.scss\";import{jsx as _jsx}from\"react/jsx-runtime\";import{jsxs as _jsxs}from\"react/jsx-runtime\";var Dialogs=function Dialogs(_ref){var chatsList=_ref.chatsList,onSearch=_ref.onSearch,inputValue=_ref.inputValue;return/*#__PURE__*/_jsxs(\"div\",{className:\"dialogs\",children:[/*#__PURE__*/_jsx(\"div\",{className:\"dialogs-item-search\",children:/*#__PURE__*/_jsx(\"div\",{className:\"dialogs-item-search-form\",children:/*#__PURE__*/_jsx(InputBase,{className:\"dialogs-item-search-form-input\",placeholder:\"\\u041F\\u043E\\u0438\\u0441\\u043A \\u0434\\u0438\\u0430\\u043B\\u043E\\u0433\\u0430\",inputProps:{'aria-label':'Поиск диалога'},onChange:function onChange(e){return onSearch&&onSearch(e.target.value);},value:inputValue})})}),//Сортировка по времени\nchatsList.items&&chatsList.items.length>0&&chatsList.items.sort(function(firstItem,secondItem){var _firstItem$lastMessag,_secondItem$lastMessa;if((_firstItem$lastMessag=firstItem.lastMessage)!==null&&_firstItem$lastMessag!==void 0&&_firstItem$lastMessag.createdAt&&(_secondItem$lastMessa=secondItem.lastMessage)!==null&&_secondItem$lastMessa!==void 0&&_secondItem$lastMessa.createdAt){var _secondItem$lastMessa2,_firstItem$lastMessag2;console.log('sd',firstItem,secondItem);return((_secondItem$lastMessa2=secondItem.lastMessage)!==null&&_secondItem$lastMessa2!==void 0&&_secondItem$lastMessa2.updatedAt?secondItem.lastMessage.updatedAt:secondItem.lastMessage.createdAt)-((_firstItem$lastMessag2=firstItem.lastMessage)!==null&&_firstItem$lastMessag2!==void 0&&_firstItem$lastMessag2.updatedAt?firstItem.lastMessage.updatedAt:firstItem.lastMessage.createdAt);}else{var _firstItem$lastMessag3;console.log('xs',firstItem,secondItem);return(_firstItem$lastMessag3=firstItem.lastMessage)!==null&&_firstItem$lastMessag3!==void 0&&_firstItem$lastMessag3.createdAt?firstItem.id-secondItem.id:secondItem.id-firstItem.id;}}).map(function(item){return/*#__PURE__*/_jsx(DialogItem,{chat:item},item.id);})||/*#__PURE__*/_jsxs(\"div\",{className:\"dialogs-item\",children:[/*#__PURE__*/_jsx(\"span\",{className:\"dialogs-item-title\",children:\"\\u0421\\u043F\\u0438\\u0441\\u043E\\u043A \\u0434\\u0438\\u0430\\u043B\\u043E\\u0433\\u043E\\u0432 \\u043F\\u0443\\u0441\\u0442\"}),/*#__PURE__*/_jsx(\"div\",{className:\"dialogs-item--noData\"})]})]});};export default Dialogs;","map":{"version":3,"names":["React","DialogItem","InputBase","Dialogs","chatsList","onSearch","inputValue","e","target","value","items","length","sort","firstItem","secondItem","lastMessage","createdAt","console","log","updatedAt","id","map","item"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/components/Dialogs/index.tsx"],"sourcesContent":["import React from 'react';\nimport {DialogsProps} from \"../../models/props/DialogsProps\";\nimport { ChatsListItem } from '../../models/response/ChatsListItem';\nimport {DialogItem} from \"../index\";\nimport {InputBase} from \"@mui/material\";\nimport \"./Dialogs.scss\";\n\nconst Dialogs: React.FC<DialogsProps> = ({chatsList, onSearch, inputValue}) => {\n    return (\n        <div className=\"dialogs\">\n            <div className=\"dialogs-item-search\">\n                <div className=\"dialogs-item-search-form\">\n                    <InputBase\n                        className=\"dialogs-item-search-form-input\"\n                        placeholder=\"Поиск диалога\"\n                        inputProps={{ 'aria-label': 'Поиск диалога' }}\n                        onChange={e => (onSearch && onSearch(e.target.value))}\n                        value={inputValue}\n                    />\n                </div>\n            </div>\n            {\n                //Сортировка по времени\n                (chatsList.items && chatsList.items.length > 0 && chatsList.items.sort((firstItem: ChatsListItem, secondItem: ChatsListItem):any => {\n                    if (firstItem.lastMessage?.createdAt! && secondItem.lastMessage?.createdAt!) {\n                        console.log('sd', firstItem, secondItem)\n                        return (\n                            ((secondItem.lastMessage?.updatedAt)?\n                                secondItem.lastMessage.updatedAt:\n                                secondItem.lastMessage.createdAt\n                            ) -\n                            ((firstItem.lastMessage?.updatedAt)?\n                                firstItem.lastMessage.updatedAt:\n                                firstItem.lastMessage.createdAt\n                            )\n                        );\n                    } else {\n                        console.log('xs', firstItem, secondItem)\n                        return (\n                            (firstItem.lastMessage?.createdAt!)?\n                                firstItem.id - secondItem.id:\n                                secondItem.id - firstItem.id\n                        );\n                    }\n                }).map((item) =>\n                    <DialogItem key={item.id} chat={item} />\n                )) || (\n                        <div className=\"dialogs-item\">\n                            <span className=\"dialogs-item-title\">Список диалогов пуст</span>\n                            <div className=\"dialogs-item--noData\" />\n                        </div>\n                )\n            }\n        </div>\n    );\n}\n\nexport default Dialogs;"],"mappings":"AAAA,MAAOA,MAAK,KAAM,OAAO,CAGzB,OAAQC,UAAU,KAAO,UAAU,CACnC,OAAQC,SAAS,KAAO,eAAe,CACvC,MAAO,gBAAgB,CAAC,wFAExB,GAAMC,QAA+B,CAAG,QAAlCA,QAA+B,MAA0C,IAArCC,UAAS,MAATA,SAAS,CAAEC,QAAQ,MAARA,QAAQ,CAAEC,UAAU,MAAVA,UAAU,CACrE,mBACI,aAAK,SAAS,CAAC,SAAS,wBACpB,YAAK,SAAS,CAAC,qBAAqB,uBAChC,YAAK,SAAS,CAAC,0BAA0B,uBACrC,KAAC,SAAS,EACN,SAAS,CAAC,gCAAgC,CAC1C,WAAW,CAAC,2EAAe,CAC3B,UAAU,CAAE,CAAE,YAAY,CAAE,eAAgB,CAAE,CAC9C,QAAQ,CAAE,kBAAAC,CAAC,QAAKF,SAAQ,EAAIA,QAAQ,CAACE,CAAC,CAACC,MAAM,CAACC,KAAK,CAAC,EAAE,CACtD,KAAK,CAAEH,UAAW,EACpB,EACA,EACJ,CAEF;AACCF,SAAS,CAACM,KAAK,EAAIN,SAAS,CAACM,KAAK,CAACC,MAAM,CAAG,CAAC,EAAIP,SAAS,CAACM,KAAK,CAACE,IAAI,CAAC,SAACC,SAAwB,CAAEC,UAAyB,CAAS,iDAChI,GAAI,uBAAAD,SAAS,CAACE,WAAW,0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